<?php
/**
 * 广告模板配置函数
 */
function get_types() {
	$poster_template = getcache('poster_template_'.$siteid, 'commons');
	$TYPES = array();
	if (is_array($poster_template) && !empty($poster_template)){
		foreach ($poster_template as $k => $template) {
			$TYPES[$k] = $template['name'];
		}
	} else {
		$TYPES = array('banner'=>L('banner'), 'fixure'=>L('fixure'), 'float'=>L('float'), 'couplet'=>L('couplet'), 'imagechange'=>L('imagechange'),  'imagelist'=>L('imagelist'), 'text'=>L('text'), 'code'=>L('code'),);
	}
	return $TYPES;
}

/**
 * 判断表是否存在
 * @param $tablename 表名
 */
	function table_exists($tablename){
		$model = new Think\Model();
		$database = C('DB_NAME');
		$sql = "SELECT COUNT(*) num FROM information_schema.tables WHERE table_schema = '[$database]' AND table_name = '[$tablename]'";
		$result = $model->query($sql);
		if($result['num'] > 0){
			return true;
		}else{
			return false;
		}
	}